<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = [4, 3, 2, 7, 8, 2, 3, 1];
    //   var  arr2 = [1,2,3,4,5,6,7,8]
      //    先找出最大的和最小的
      
      arr.sort(function(a,b){return b-a});
       
      var max = arr[0];
      arr.sort(function(a,b){return a-b});
      var min = arr[0]
      var arr2 = []
     for(var i=min;i<=max;i++){
         
          arr2.push(i)
     }
    var arr3 = []
    for(var j=0;j<arr2.length;j++){
        if(arr.indexOf(arr2[j]) ==-1){
         arr3.push(arr2[j])
        }
        
    }
    
    console.log(arr3)
    


    </script>
  </body>
</html>
